package com.focusai.efairy.ui.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.focusai.efairy.R;

/**
 * Created by luo_guangwen on 2017/7/31.
 */

public class ContentViewFramLayout extends FrameLayout {
    private ImageView iv_no_data;

    public ContentViewFramLayout(Context context) {
        super(context);
    }

    public ContentViewFramLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
        initView(context, attrs);
    }

    public ContentViewFramLayout(Context context, AttributeSet attrs, int defStryle) {
        super(context, attrs, defStryle);
        initView(context, attrs);
    }

    private void initView(Context context, AttributeSet attrs) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.view_no_data_tip, this);
        iv_no_data = (ImageView) view.findViewById(R.id.iv_no_data);
        iv_no_data.setVisibility(GONE);
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.no_data_view);
        if (array != null) {
            boolean visiblenble = array.getBoolean(R.styleable.no_data_view_iv_visible, false);
            iv_no_data.setVisibility(visiblenble ? VISIBLE : GONE);
            array.recycle();
        }

    }

    public ImageView getmTipView() {
        return iv_no_data;
    }

}
